package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    @Select("select count(1) from setmeal_dish where dish_id = #{dishId}")
    Integer countByDishId(Long dishId);

    void saveBatch(List<SetmealDish> setmealDishes);

    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getSetmealDishes(Integer setmealId);

    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);

    void deleteBySetmealIds(List<Long> ids);

    @Select("SELECT count(sd.dish_id) FROM setmeal_dish sd join dish d on sd.dish_id=d.id WHERE d.`status`=0 and sd.setmeal_id=#{id}")
    Integer countBySetmealId(Long id);
}
